package com.far.game.xiuzhen.common.exception;


import com.far.game.xiuzhen.common.enums.BizCodes;

/*
 * @description: TODO
 * @author mike/Fang.J/Q184377367
 * @date 2022/4/10 0:50
 */
public class BizException extends RuntimeException {

    private static final long serialVersionUID = 1L;


    /**
     * 业务错误码 根据系统来...
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public BizException() {
        super();
    }


    public BizException(BizCodes err) {
        super(err.getCode());
        this.errorCode = err.getCode();
        this.errorMsg = err.getVal();
    }


    public BizException(BaseErrorInfoInterface err, Throwable cause) {
        super(err.getCode(), cause);
        this.errorCode = err.getCode();
        this.errorMsg = err.getMsg();
    }

    public BizException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BizException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    //系统异常转发到BizExp
    public BizException(Exception e) {
//        this.errorCode = BizCodes.PRODUCT_SYS_EXP.getCode();
//        this.errorMsg = BizCodes.PRODUCT_SYS_EXP.getVal() + "->" + e.getMessage();
    }


    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getMessage() {
        return errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

}

